
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  
  <title>Docker安装教程 | 野生博主不在家</title>
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <meta name="description" content="Docker简介Docker是一个开源的容器化平台，可帮助开发者轻松地创建、部署和运行应用程序。Docker使开发人员能够在一个独立的容器中打包应用程序及其依赖项，可以将应用程序移植到任何其他环境中。 Doker安装123456789101112131415161718192021222324#卸载系统之前可能安装的dockersudo yum remove docker \    docker-">
<meta property="og:type" content="article">
<meta property="og:title" content="Docker安装教程">
<meta property="og:url" content="https://pengzzhao.github.io/2024/10/09/Docker%E5%AE%89%E8%A3%85%E6%95%99%E7%A8%8B/index.html">
<meta property="og:site_name" content="野生博主不在家">
<meta property="og:description" content="Docker简介Docker是一个开源的容器化平台，可帮助开发者轻松地创建、部署和运行应用程序。Docker使开发人员能够在一个独立的容器中打包应用程序及其依赖项，可以将应用程序移植到任何其他环境中。 Doker安装123456789101112131415161718192021222324#卸载系统之前可能安装的dockersudo yum remove docker \    docker-">
<meta property="og:locale" content="zh_CN">
<meta property="article:published_time" content="2024-10-08T16:00:00.000Z">
<meta property="article:modified_time" content="2024-10-09T09:20:46.501Z">
<meta property="article:author" content="Evelia">
<meta property="article:tag" content="docker python jenkins">
<meta name="twitter:card" content="summary">
  
  
    <link rel="icon" href="/favicon.png">
  
  
<link rel="stylesheet" href="/css/style.css">

  <!--[if lt IE 9]><script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7/html5shiv.min.js"></script><![endif]-->
  
<meta name="generator" content="Hexo 7.3.0"></head>
<body>
<div id="container">
  <div id="wrap">
    <header id="header">
  <div id="banner"></div>
  <div id="header-outer" class="outer">
    <div id="header-title" class="inner">
      <h1 id="logo-wrap">
        <a href="/" id="logo">野生博主不在家</a>
      </h1>
      
    </div>
    <div id="header-inner" class="inner">
      <nav id="main-nav">
        <a id="main-nav-toggle" class="nav-icon"></a>
        
          <a class="main-nav-link" href="/">Home</a>
        
          <a class="main-nav-link" href="/archives">Archives</a>
        
      </nav>
      <nav id="sub-nav">
        
        <a id="nav-search-btn" class="nav-icon" title="Search"></a>
      </nav>
      <div id="search-form-wrap">
        <form action="//www.baidu.com/baidu" method="get" accept-charset="utf-8" class="search-form">
          <input type="search" name="word" maxlength="20" class="search-form-input" placeholder="Search">
          <input type="submit" value="" class="search-form-submit">
          <input name=tn type=hidden value="bds">
          <input name=cl type=hidden value="3">
          <input name=ct type=hidden value="2097152">
          <input type="hidden" name="si" value="pengzzhao.github.io">
        </form>
      </div>
    </div>
  </div>
</header>
    <div class="outer">
      <section id="main"><article id="post-Docker安装教程" class="article article-type-post" itemscope itemprop="blogPost">
  <div class="article-meta">
    <a href="/2024/10/09/Docker%E5%AE%89%E8%A3%85%E6%95%99%E7%A8%8B/" class="article-date">
  <time datetime="2024-10-08T16:00:00.000Z" itemprop="datePublished">2024-10-09</time>
</a>
    
  </div>
  <div class="article-inner">
    
    
      <header class="article-header">
        
  
    <h1 class="article-title" itemprop="name">
      Docker安装教程
    </h1>
  

      </header>
    
    <div class="article-entry" itemprop="articleBody">
      
        <h3 id="Docker简介"><a href="#Docker简介" class="headerlink" title="Docker简介"></a>Docker简介</h3><p>Docker是一个开源的容器化平台，可帮助开发者轻松地创建、部署和运行应用程序。Docker使开发人员能够在一个独立的容器中打包应用程序及其依赖项，可以将应用程序移植到任何其他环境中。</p>
<h3 id="Doker安装"><a href="#Doker安装" class="headerlink" title="Doker安装"></a>Doker安装</h3><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">#卸载系统之前可能安装的docker</span></span><br><span class="line"><span class="built_in">sudo</span> yum remove docker \</span><br><span class="line">    docker-client \</span><br><span class="line">    docker-client-latest \</span><br><span class="line">    docker-common \</span><br><span class="line">    docker-latest \</span><br><span class="line">    docker-latest-logrotate \</span><br><span class="line">    docker-logrotate \</span><br><span class="line">    docker-engine</span><br><span class="line"></span><br><span class="line"><span class="comment">#安装必须的依赖</span></span><br><span class="line"><span class="built_in">sudo</span> yum install -y yum-utils \ </span><br><span class="line">device-mapper-persistent-data \ </span><br><span class="line">lvm2</span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="comment">#设置docker源地址</span></span><br><span class="line"><span class="built_in">sudo</span> yum-config-manager \ </span><br><span class="line">--add-repo \ </span><br><span class="line">https://download.docker.com/linux/centos/docker-ce.repo </span><br><span class="line"></span><br><span class="line"><span class="comment">#安装 docker</span></span><br><span class="line"><span class="built_in">sudo</span> yum install docker-ce docker-ce-cli containerd.io</span><br><span class="line"></span><br></pre></td></tr></table></figure>

<h3 id="启动-docker"><a href="#启动-docker" class="headerlink" title="启动 docker"></a>启动 docker</h3><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">#启动docker</span></span><br><span class="line"><span class="built_in">sudo</span> systemctl start docker</span><br><span class="line"><span class="comment">#查看docker服务状态 running 就是启动成功</span></span><br><span class="line"><span class="built_in">sudo</span> systemctl status docker</span><br><span class="line"></span><br><span class="line"><span class="comment">#设置 docker 开机自启</span></span><br><span class="line"><span class="built_in">sudo</span> systemctl <span class="built_in">enable</span> docker</span><br><span class="line"></span><br></pre></td></tr></table></figure>
<h3 id="docker-常用命令"><a href="#docker-常用命令" class="headerlink" title="docker 常用命令"></a>docker 常用命令</h3><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">#镜像命令</span></span><br><span class="line">docker images：列出所有镜像</span><br><span class="line">docker search [image]：搜索 Docker 镜像</span><br><span class="line">docker pull [image]：拉取指定镜像</span><br><span class="line">docker rmi [image]：删除指定镜像</span><br><span class="line"><span class="comment">#容器命令</span></span><br><span class="line">docker ps：列出当前所有正在运行的容器</span><br><span class="line">docker ps -a：列出所有容器，包括已经停止的容器</span><br><span class="line">docker create [image]：创建一个新的容器，但不启动它</span><br><span class="line">docker start [container]：启动一个容器</span><br><span class="line">docker stop [container]：停止一个容器</span><br><span class="line">docker <span class="built_in">rm</span> [container]：删除一个容器</span><br><span class="line">docker <span class="built_in">exec</span> -it [container] [<span class="built_in">command</span>]：在运行中的容器中执行命令</span><br><span class="line"><span class="comment">#其他命令</span></span><br><span class="line">docker info：显示 Docker 系统信息</span><br><span class="line">docker version：显示 Docker 版本信息</span><br><span class="line">docker logs [container]：查看容器的日志</span><br><span class="line">docker network <span class="built_in">ls</span>：列出 Docker 网络</span><br><span class="line">docker network create [network]：创建一个新的 Docker 网络</span><br><span class="line">docker network connect [network] [container]：将容器连接到指定的 Docker 网络</span><br><span class="line">docker network disconnect [network] [container]：将容器从指定的 Docker 网络中断开连接 </span><br><span class="line"></span><br></pre></td></tr></table></figure>
      
    </div>
    <footer class="article-footer">
      
        <a data-url="https://pengzzhao.github.io/2024/10/09/Docker%E5%AE%89%E8%A3%85%E6%95%99%E7%A8%8B/" data-id="cm21irup00000t6d81hle4nua" class="article-share-link">分享到</a>
      

      

      
    </footer>
  </div>
  
    
<nav id="article-nav">
  
    <a href="/2024/10/11/Podman%E5%AE%89%E8%A3%85%E6%95%99%E7%A8%8B/" id="article-nav-newer" class="article-nav-link-wrap">
      <strong class="article-nav-caption">下一篇</strong>
      <div class="article-nav-title">
        
          Podman安装教程
        
      </div>
    </a>
  
  
    <a href="/2024/10/09/Harbor%E4%BB%93%E5%BA%93%E5%AE%89%E8%A3%85%E6%95%99%E7%A8%8B/" id="article-nav-older" class="article-nav-link-wrap">
      <strong class="article-nav-caption">上一篇</strong>
      <div class="article-nav-title">Harbor仓库安装教程</div>
    </a>
  
</nav>

  
</article>

</section>
      
      <aside id="sidebar">
  
    
  
    
  
    
  
    
  <div class="widget-wrap">
    <h3 class="widget-title">归档</h3>
    <div class="widget">
      <ul class="archive-list"><li class="archive-list-item"><a class="archive-list-link" href="/archives/2024/10/">十月 2024</a><span class="archive-list-count">4</span></li></ul>
    </div>
  </div>

  
    
  <div class="widget-wrap">
    <h3 class="widget-title">近期文章</h3>
    <div class="widget">
      <ul>
        
          <li>
            <a href="/2024/10/11/Podman%E5%AE%89%E8%A3%85%E6%95%99%E7%A8%8B/">Podman安装教程</a>
          </li>
        
          <li>
            <a href="/2024/10/09/Docker%E5%AE%89%E8%A3%85%E6%95%99%E7%A8%8B/">Docker安装教程</a>
          </li>
        
          <li>
            <a href="/2024/10/09/Harbor%E4%BB%93%E5%BA%93%E5%AE%89%E8%A3%85%E6%95%99%E7%A8%8B/">Harbor仓库安装教程</a>
          </li>
        
          <li>
            <a href="/2024/10/09/Jenkins%E5%AE%89%E8%A3%85%E6%95%99%E7%A8%8B/">Jenkins安装教程</a>
          </li>
        
      </ul>
    </div>
  </div>

  
    
  <div class="widget-wrap">
    <h3 class="widget-title">友情链接</h3>
    <div class="widget">
      <ul>
        
          <li>
            <a href="http://arvinxiang.com" target="_blank">主题作者</a>
          </li>
        
      </ul>
    </div>
  </div>

  
</aside>
      
    </div>
    <footer id="footer">
  
  <div class="outer">
    <div id="footer-info" class="inner">
      &copy; 2024 Evelia<br>
      Powered by <a href="//hexo.io/" target="_blank">Hexo</a>
      .
      Theme by <a href="https://github.com/xiangming/landscape-plus" target="_blank">Landscape-plus</a>
    </div>
  </div>
</footer>
  </div>
  <nav id="mobile-nav">
  
    <a href="/" class="mobile-nav-link">Home</a>
  
    <a href="/archives" class="mobile-nav-link">Archives</a>
  
</nav>
  <!-- totop start -->
<div id="totop">
<a title="返回顶部"><img src="/img/scrollup.png"/></a>
</div>

<!-- totop end -->


<!-- 百度分享 start -->

<!-- 百度分享 end -->

<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>





<script src="/js/script.js"></script>


</div>
</body>
</html>
